from django.contrib.auth.models import AbstractUser
from django.db import models

from django.db import models

class DashboardData(models.Model):
    user_count = models.IntegerField(default=0)
    dataset_count = models.IntegerField(default=0)
    detection_count = models.IntegerField(default=0)
    week_detection_count = models.IntegerField(default=0)
    month_detection_count = models.IntegerField(default=0)
    defect_status = models.JSONField(default=dict)  # 用于存储缺陷状态数据的JSON字段

    def __str__(self):
        return f"Dashboard Data {self.id}"


class PCBImage(models.Model):
    original_image = models.ImageField(upload_to='images/original/')
    detected_image = models.ImageField(upload_to='images/detected/', null=True, blank=True)
    uploaded_at = models.DateTimeField(auto_now_add=True)
    class Meta:
        managed = True
        db_table = "PCBImage"

    def __str__(self):
        return f"{self.original_image} - {self.detected_image}"

class DetectionResult(models.Model):
    image_name = models.CharField(max_length=255)
    labels = models.TextField()  # 存储检测类型
    confidences = models.TextField()  # 存储置信度
    created_at = models.DateTimeField(auto_now_add=True)
